# -*- coding: utf-8 -*-
"""
Created on Wed Nov 02 17:11:21 2016

@author: Divyashri Sreedharan Nair
"""

from androguard.core.androgen import AndroguardS
from androguard.core.bytecodes import dvm, apk 
from androguard.core.analysis import analysis, ganalysis
from androguard.decompiler import decompiler

import os
cwd = os.getcwd()

def grab_filename(apk) :
	"""
		@param apk : an APK instance
		@rtype : the APK's filename
	"""
	return apk.filename.split('/')[-1]

def grab_androidversion_name(apk) :
	"""
		@param apk : an APK instance
		@rtype : the android version name 
	"""
	return apk.get_androidversion_name()
 
def grab_application_package_name(apk) :
	"""
		@param apk : an APK instance
		@rtype : the package name
	"""
	return apk.get_package()
 
def grab_application_permission_list(apk) :
	"""
		@param apk : an APK instance
		@rtype : the permission list
	"""
	return apk.get_permissions()

def grab_application_activity_list(apk) :
	"""
		@param apk : an APK instance
		@rtype : the activity list
	"""
	return apk.get_activities()
 
def grab_application_provider_list(apk) :
	"""
		@param apk : an APK instance
		@rtype : the provider list
	"""
	return apk.get_providers()

def grab_application_receiver_list(apk) :
	"""
		@param apk : an APK instance
		@rtype : the reciever list
	"""
	return apk.get_receivers()
 
def grab_file_list(apk) :
	"""
		@param apk : an APK instance
		@rtype : the file list inside the AP
	"""
	return apk.get_files()


print("=====================================")
TEST = "C:/Users/admin/Desktop/samples/samples/ADRD/ffe62967b75aab56710110b26baa69acd47a81dd.apk"

a = apk.APK(TEST)
print "\nAPK Filename: \n"+ str(grab_filename(a))
print "\nAndroid Version: \n"+ str(grab_androidversion_name(a))
print "\nPermision List: \n"+ str(grab_application_permission_list(a))
print "\nActivity List: \n"+ str(grab_application_activity_list(a))
print "\nPackage Name: \n"+  str(grab_application_package_name(a))
print "\nProvider List: \n"+  str(grab_application_provider_list(a))
print "\nReceiver List: \n"+  str(grab_application_receiver_list(a))
print "\nAPK file List: \n"+ str(grab_file_list(a))
print("=====================================")